package com.twu.biblioteca;


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Runner {
    public static void main(String[] args)  {
        System.out.println("welcome to biblioteca");
        LoginManager loginManager=new LoginManager();
        Library library=new Library(loginManager);
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        HashMap<Integer,Task> ListOfActions=new HashMap<Integer, Task>();
        ListOfActions.put(1,new ListBooks(library));
        ListOfActions.put(2,new ListMovies(library));
        ListOfActions.put(3,new Login(loginManager));
        ListOfActions.put(4,new CheckOut(library));
        ListOfActions.put(5,new Return(library));
        ListOfActions.put(6,new Logout(loginManager));
        ListOfActions.put(7,new Exit());
        int choice = 0;
        do {
            try {
                for (int i = 1; i <= ListOfActions.size(); i++) {
                    System.out.println(i+"."+String.valueOf(ListOfActions.get(i).getClass()).substring(25));
                }
                System.out.println("\nenter your choice");
                choice = Integer.parseInt(in.readLine());
                Task task=ListOfActions.get(choice);
                if(task==null)
                    System.out.println("enter a valid choice");
                else
                    task.execute();
            }
            catch (Exception e)
            {
                System.out.println(e);
            }
        } while (choice!=6) ;
    }
}
